package cn.ycc1.mymiddle.config;

import com.alibaba.cloud.ai.dashscope.api.DashScopeApi;
import com.alibaba.cloud.ai.dashscope.rag.DashScopeCloudStore;
import com.alibaba.cloud.ai.dashscope.rag.DashScopeStoreOptions;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 向量，知识库配置类
 * @author ycc
 * @date 2025/5/2
 */
@Configuration
public class VectorConfig {
//    @Value("${spring.ai.dashscope.api-key}") // 从配置读取API密钥
//    private String dashscopeApiKey;
//
//    // 1. 先创建 DashScopeApi 客户端
//    @Bean
//    public DashScopeApi dashScopeApi() {
//        return new DashScopeApi(dashscopeApiKey); // 使用API密钥初始化
//    }

    // 2. 再创建 DashScopeCloudStore 知识库客户端
    @Bean
    public DashScopeCloudStore sashScopeCloudStore(DashScopeApi dashscopeApi) {
        DashScopeCloudStore cloudStore = new DashScopeCloudStore(
                dashscopeApi, new DashScopeStoreOptions("cc-springai-alibaba"));
        return cloudStore;
    }
}
